
class Click extends Behaviour {
    @SerializedField()
    content: string;

    onStart() {
        const content = this.content;
        this.gameObject.onClick = function () {
            console.log(content);
        }

    }
}
core.registerBehaviour(Click);

class playAudioOnClick extends Behaviour {
    onStart(){
        const audioplayer = this.gameObject.audioPlayer;
        this.gameObject.onClick = function(){
            audioplayer.playAudio();
            console.log("音频")
        }
    }
}
core.registerBehaviour(playAudioOnClick);
class MoveBehaviour extends Behaviour {

    @SerializedField(1000)
    time: number;
    @SerializedField(0)
    targetX: number;


    private currentTime = 0;
    private initX = 0;

    isDestory = false;


    onStart() {
        this.initX = this.getTransform().x;
    }

    getTransform() {
        return this.gameObject.getBehaviour(Transform);
    }

    onUpdate(duringTime) {
        const transform = this.getTransform();
        this.currentTime += duringTime;
        let timeRatio = this.currentTime / this.time;
        if (timeRatio > 1) {
            timeRatio = 1;
        }
        const needToMoveX = this.targetX - this.initX;
        transform.x = this.initX + timeRatio * needToMoveX;
        if (timeRatio == 1) {
            this.gameObject.removeBehaviour(this);
        }
    }

    onDestroy() {

    }
}
core.registerBehaviour(MoveBehaviour);

class gamestartupBehaviour extends Behaviour {
    onStart() {
        // const prefab = core.createPrefab("");
        // setTimeout(() => {
        //     core.changeScene("bb.json")
        // }, 3000);
    }
}
core.registerBehaviour(gamestartupBehaviour);